package com.yc.domain;

import lombok.Builder;
import lombok.Data;

@Data
@Builder //提供一个构造器
public class JsonModel {

    private int code;
    private String msg;
    private Object obj;

    public static JsonModel ok() {
        return JsonModel.builder().code(1).msg("成功").build();
    }

    public static JsonModel ok(Object data) {
        return JsonModel.builder().code(1).msg("成功").obj(data).build();
    }

    public static JsonModel err() {
        return JsonModel.builder().code(0).msg("失败").build();
    }

    public static JsonModel err(String msg) {
        return JsonModel.builder().code(0).msg(msg).build();
    }

    public <T> JsonModel setData(T data) {
        this.obj = data;
        return this;
    }

}
